from fastapi import APIRouter, BackgroundTasks, Depends

from forward.api.admin.schemas.lucky.code_batch import (
    CodeBatchAddInSchema,
    CodeBatchDeleteInSchema,
    CodeBatchDetailInSchema,
    CodeBatchEditInSchema,
    CodeBatchExportInSchema,
    CodeBatchGenerateInSchema,
    CodeBatchListInSchema,
    CodeBatchStatusInSchema,
)
from forward.api.admin.service.lucky.code_batch import CodeBatchService

code_batch = APIRouter(prefix="/code_batch")


@code_batch.post("/lists")
async def lists(
    list_in: CodeBatchListInSchema,
    code_batch_service: CodeBatchService = Depends(),
):
    return await code_batch_service.lists(list_in)


@code_batch.post("/add")
async def add(
    add_in: CodeBatchAddInSchema,
    code_batch_service: CodeBatchService = Depends(),
):
    return await code_batch_service.add(add_in)


@code_batch.post("/delete")
async def delete(
    delete_in: CodeBatchDeleteInSchema,
    code_batch_service: CodeBatchService = Depends(),
):
    return await code_batch_service.delete(delete_in)


@code_batch.post("/detail")
async def detail(
    detail_in: CodeBatchDetailInSchema,
    code_batch_service: CodeBatchService = Depends(),
):
    return await code_batch_service.detail(detail_in)


@code_batch.post("/edit")
async def edit(
    edit_in: CodeBatchEditInSchema,
    code_batch_service: CodeBatchService = Depends(),
):
    return await code_batch_service.edit(edit_in)


@code_batch.post("/status")
async def status(
    status_in: CodeBatchStatusInSchema,
    code_batch_service: CodeBatchService = Depends(),
):
    return await code_batch_service.status(status_in)


@code_batch.post("/generate")
async def generate(
    generate_in: CodeBatchGenerateInSchema,
    background_tasks: BackgroundTasks,
    code_batch_service: CodeBatchService = Depends(),
):

    return await code_batch_service.generate(generate_in, background_tasks)


@code_batch.post("/export")
async def export(
    export_in: CodeBatchExportInSchema,
    code_batch_service: CodeBatchService = Depends(),
):

    return await code_batch_service.export(export_in)


@code_batch.post("/file_download_url")
async def get_file_download_url(
    export_in: CodeBatchExportInSchema,
    code_batch_service: CodeBatchService = Depends(),
):

    return await code_batch_service.get_file_download_url(export_in)
